
SET(SRC_FILES
	Semol.cpp
	SemolThread.cpp
	
	Statistics.cpp
	
	Memory.cpp
	SensoryMemory.cpp
	
	DBDriver.cpp
	DBTrash.cpp
	DBReader.cpp
	
	BayesFilter.cpp
	Parameters.cpp
    Node.cpp
)

SET(INCLUDE_DIRS
	${CMAKE_CURRENT_SOURCE_DIR}/../include
	${CMAKE_CURRENT_SOURCE_DIR}
	${CMAKE_CURRENT_BINARY_DIR}
	${UtiLite_INCLUDE_DIRS}
    ${OpenCV_INCLUDE_DIRS}
	${SQLITE3_INCLUDE_DIR}
	${ZLIB_INCLUDE_DIRS}
	${FFTW3F_INCLUDE_DIRS}
)

SET(LIBRARIES
    ${UtiLite_LIBRARIES}
	${OpenCV_LIBS} 
	${SQLITE3_LIBRARY}
	${ZLIB_LIBRARIES}
	${FFTW3F_LIBRARIES}
)

####################################
# Generate resources files
####################################
SET(R
	${CMAKE_CURRENT_SOURCE_DIR}/resources/DatabaseSchema.sql
)

#replace semicolons by spaces
foreach(arg ${R})
   set(RESOURCES "${RESOURCES}" "${arg}")
endforeach(arg ${R})

SET(RESOURCES_HEADERS 
	${CMAKE_CURRENT_BINARY_DIR}/DatabaseSchema_sql.h 
)

ADD_CUSTOM_COMMAND(
   OUTPUT ${RESOURCES_HEADERS}
   COMMAND ${UtiLite_RESOURCEGENERATOR} -n semol -p ${CMAKE_CURRENT_BINARY_DIR} ${RESOURCES}
   COMMENT "[Creating resources]"
   DEPENDS ${R}
)

####################################
# Generate resources files END
####################################


# Make sure the compiler can find include files from our library.
INCLUDE_DIRECTORIES(${INCLUDE_DIRS})

# Add binary that is built from the source file "main.cpp".
# The extension is automatically found.
ADD_LIBRARY(corelib ${SRC_FILES} ${RESOURCES_HEADERS})
TARGET_LINK_LIBRARIES(corelib ${LIBRARIES})

SET_TARGET_PROPERTIES(
corelib 
PROPERTIES
 OUTPUT_NAME ${PROJECT_PREFIX}_core
 INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib
)

INSTALL(TARGETS corelib
        RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT runtime
        LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT devel
        ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT devel)
		
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../include/ 
		DESTINATION "${INSTALL_INCLUDE_DIR}"
		COMPONENT devel 
		FILES_MATCHING PATTERN "*.h" 
		PATTERN ".svn" EXCLUDE)